package com.woniu.woniuproject.web;

import com.woniu.woniuproject.entity.Product;
import com.woniu.woniuproject.entity.User;
import com.woniu.woniuproject.service.ProductService;
import com.woniu.woniuproject.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 功能描述:<br>
 * 〈〉
 *
 * @author EDZ
 * @create 2020/11/20
 * @since 1.0.0
 */
@RestController
@RequestMapping("productweb")
public class ProductControllerWeb {

    @Autowired
    ProductService productService;
    @GetMapping("queryall")
    public ResponseResult<List<Product>> queryall(){
        List<Product> queryall = productService.queryall();
        return new ResponseResult<>(queryall);
    }

    @RequestMapping("queryuser")
    public ResponseResult<String> queryuser(HttpServletRequest req){
        User userLogin =(User) req.getSession().getAttribute("loginUser");
        System.out.println(userLogin+"==========");
        if(userLogin!=null){
            return new ResponseResult<>("1");
        }else{
            return new ResponseResult<>("0");
        }
    }

}